import r from '@/plugins/request/js/index';
export const loginUsername = (data) => {
	return r.request({
		url: '/mall-cloud-system/authService/login',
		method: 'post',
		meta: {
			isToken: false
		},
		data: {
			...data,
		}
	})
}
export const getApiUserInfo = () => {
	return r.request({
		url: '/mall-cloud-system/buyerUser/getUserInfo',
		method: 'post',
		meta: {
			isToken: true
		},
	})
}
export const getUserInfo = () => {
	return r.request({
		url: '/mall-cloud-base/buyerUser/getUserAddressInfo',
		method: 'post',
		meta: {
			isToken: true
		},
	})
}
export const getUserAccount = () => { //用户余额,账户
	return r.request({
		url: '/mall-cloud-account/buyerUserAccount/detail',
		method: 'post',
		meta: {
			isToken: true
		},
	})
}
export const getAllDict = () => { //字典
	return r.request({
		url: '/mall-cloud-system/enumDict/allDict',
		method: 'post',
		meta: {
			isToken: true
		},
	})
}



//刷新token
export const refeshToken = (reftoken) => {
	return r.request({
		url: '/mall-cloud-system/authService/refresh',
		method: 'post',
		meta: {
			isToken: false
		},
		data: {
			"rToken": reftoken
		}
	})
}


export const wxlogin = (url, params) => {
	return r.request({
		url,
		method: 'post',
		meta: {
			isToken: false
		},
		data: {
			...params
		}
	})
}

export const uploadImImg = (path, album_code) => {
	let instance = r.upload('/mall-cloud-res/album/sys_img_upload', {
		name: 'file',
		method: 'post',
		filePath: path,
		header: {},
		meta: {
			isToken: true
		},
		params: {
			album_code,
		},
		onProgressUpdate (res) {
		}
	});
	// 10s 之后还没上传完成就中断上传，会进入 catch 回调中
	setTimeout(() => {
		r.abort(instance);
	}, 10000);

	return instance;
}
// 第三方微信登陆
export const appWxLogin = (unionId) => {
	return r.request({
		url: '/mall-cloud-system/authService/appWxLogin',
		method: 'post',
		meta: {
			isToken: false
		},
		data: {
			unionId
		}
	})
}
// 第三方QQ登陆
export const appQQLogin = (openId) => {
	return r.request({
		url: '/mall-cloud-system/authService/appQQLogin',
		method: 'post',
		meta: {
			isToken: false
		},
		data: {
			openId
		}
	})
}
// 第三方手机号绑定
export const appBindLogin = (data) => {
	return r.request({
		url: '/mall-cloud-system/authService/appBindLogin',
		method: 'post',
		meta: {
			isToken: false
		},
		data: data
	})
}


